from math import *


TrainSum = 72

#获取数据
a = input().split(" ")
b = input().split(" ")
c = input().split(" ")
d = input().split(" ")
x = input().split(" ")

a = [float(item) for item in a]
b = [float(item) for item in b]
c = [float(item) for item in c]
d = [float(item) for item in d]
x = [float(item) for item in x]


TrainTime = int(input())


TrainLis = input().split(" ")  #应该填写72个数据，下同
ChangeNumlis = input().split(" ")

TrainLis = [float(item) for item in TrainLis]
ChangeNumlis = [float(item) for item in ChangeNumlis]


NowChange = int(input())
#获取数据 end


#计算结果
def cac(a,b,c,d):
    global TrainTime,TrainLis,ChangeNumlis,NowChange
    try:
        res11 = ChangeNumlis[0]*(a**ChangeNumlis[1])+ChangeNumlis[2]*(b**ChangeNumlis[3])+ChangeNumlis[4]*(c**ChangeNumlis[5])+ChangeNumlis[6]*(d**ChangeNumlis[7])
        res12 = ChangeNumlis[8]*(a**ChangeNumlis[9])+ChangeNumlis[10]*(b**ChangeNumlis[11])+ChangeNumlis[12]*(c**ChangeNumlis[13])+ChangeNumlis[14]*(d**ChangeNumlis[15])
        res13 = ChangeNumlis[16]*(a**ChangeNumlis[17])+ChangeNumlis[18]*(b**ChangeNumlis[19])+ChangeNumlis[20]*(c**ChangeNumlis[21])+ChangeNumlis[22]*(d**ChangeNumlis[23])
        res14 = ChangeNumlis[24]*(a**ChangeNumlis[25])+ChangeNumlis[26]*(b**ChangeNumlis[27])+ChangeNumlis[28]*(c**ChangeNumlis[29])+ChangeNumlis[30]*(d**ChangeNumlis[31])

        res21 = ChangeNumlis[32]*(res11**ChangeNumlis[33])+ChangeNumlis[34]*(res12**ChangeNumlis[35])+ChangeNumlis[36]*(res13**ChangeNumlis[37])+ChangeNumlis[38]*(res14**ChangeNumlis[39])
        res22 = ChangeNumlis[40]*(res11**ChangeNumlis[41])+ChangeNumlis[42]*(res12**ChangeNumlis[43])+ChangeNumlis[44]*(res13**ChangeNumlis[45])+ChangeNumlis[46]*(res14**ChangeNumlis[47])
        res23 = ChangeNumlis[48]*(res11**ChangeNumlis[49])+ChangeNumlis[50]*(res12**ChangeNumlis[51])+ChangeNumlis[52]*(res13**ChangeNumlis[53])+ChangeNumlis[54]*(res14**ChangeNumlis[55])
        res24 = ChangeNumlis[56]*(res11**ChangeNumlis[57])+ChangeNumlis[58]*(res12**ChangeNumlis[59])+ChangeNumlis[60]*(res13**ChangeNumlis[61])+ChangeNumlis[62]*(res14**ChangeNumlis[63])

        res = ChangeNumlis[64]*(res21**ChangeNumlis[65])+ChangeNumlis[66]*(res22**ChangeNumlis[67])+ChangeNumlis[68]*(res23**ChangeNumlis[69])+ChangeNumlis[70]*(res24**ChangeNumlis[71])
        return res
    except ZeroDivisionError:
        print("[error]0.0 is raised to a negative power")
        return -1
#计算结果 end


#计算方差
def cacDev():
    global a,b,c,d,x
    global TrainTime,TrainLis,ChangeNumlis,NowChange

    res = 0.0
    for i in range(len(a)):
        if(cac(a[i],b[i],c[i],d[i]) == -1):
            return -1
        res += (cac(a[i],b[i],c[i],d[i])-x[i])**2

    return res
#计算方差 end


#更改函数
def change(BefDeviation):
    global a,b,c,d,x
    global TrainTime,TrainLis,ChangeNumlis,NowChange
    LTrainNum = TrainLis[NowChange]
    TrainLis[NowChange] += ChangeNumlis[NowChange]

    AftDeviation = cacDev()

    if(AftDeviation < BefDeviation  and  AftDeviation != -1):
        ChangeNumlis[NowChange] *= 2
        return AftDeviation
    elif(AftDeviation == -1):
        ChangeNumlis[NowChange] *= -1
        TrainLis[NowChange] = LTrainNum
        return BefDeviation
    else:
        ChangeNumlis[NowChange] *= -0.5
        TrainLis[NowChange] = LTrainNum
        return BefDeviation
#更改函数 end


#主函数
def main():
    global a,b,c,d,x
    global TrainTime,TrainLis,ChangeNumlis,NowChange

    Deviation = cacDev()
    for i in range(TrainTime):
        Deviation = change(Deviation)
        NowChange = (NowChange+1)%TrainSum
    

    print(Deviation)
    for i in range(TrainSum):
        print(str(TrainLis[i]),end=" ")
    
    print()
    for i in range(TrainSum):
        print(str(ChangeNumlis[i]),end=" ")
#主函数 end

main()